<template>
  <div class="c-minh" :class="type==1 || type==2 || type==5 || type==6 ? 'c-bg-f569' : ''">
    <div class="c-ph24" v-if="type == 1">
      <div class="c-flex-column c-aligni-center" v-for="(item,index) in messageList" :key="index">
        <div class="c-bg-white c-br8 c-ph20 c-w100 c-mt20 c-flex-column">
          <h2 class="c-fw-b c-fs26 c-pt24 c-fc-xblack" v-if="item.title || item.title.length > 0">{{item.title}}</h2>
          <div class="c-w100 c-flex-row c-pb20 c-pt24" :class="isShowLookDetail(item) ? 'c-bd-b1-ef':''">
            <div class="c-ww210 c-maxh140 c-br10">
              <img v-if="item.prodType == cfrom.vip || item.prodType == cfrom.svip || item.prodType == cfrom.presentVip || item.prodType == cfrom.presentSvip || item.prodType == cfrom.shareholderPayVoucher" :src="$addXossFilter(item.avatar ? (item.avatar.coverType == 2 ? item.avatar.coverUrl : ((item.avatar.coverType == 1 && item.prodType == 23) ? require('../../assets/i/wap/course/svip.png') : require('../../assets/i/wap/course/vip.png'))) : item.prodType == cfrom.shareholderPayVoucher ? require('@/assets/shareholderPayVoucher.png') : require('../../assets/i/wap/course/vip.png'))" class="c-w100 c-maxh c-br10" />
              <img v-else :src="$addXossFilter(item.avatar, 'https://kposshzcdn.ckjr001.com/admin/material/9_material_admin/image/assets/i/wap/common/activity.jpg')" class="c-w100 c-h c-maxh140 c-br10" />
            </div>
            <div class="c-flex-column c-flex-grow1 c-w0 c-flex-shrink0 c-ml16 c-fs20 c-p">
              <div :ref='`msgContent${index}`' :class="item.hasShowMore && !item.showAllContent ? 'c-text-hidden':''" class="c-lh36 c-fc-sblack c-ww-ba" v-html="item.content"></div>
              <div @click="clickShowMore(index)" v-if="item.hasShowMore" class="c-fs20 c-pt8 c-w100 c-lh36 c-bg-white c-fc-gray c-text-decoration-underline">
                <span>{{item.showAllContent ? '收起':'展开'}}</span>
              </div>
            </div>

          </div>
          <div class="c-flex-row c-aligni-center c-justify-sb c-pv24">
            <span class="c-fs20 c-fc-gray">{{item.pushTime}}</span>
            <div class="c-fw-n c-fs20 theme-fc c-flex-row c-aligni-center" v-if="isShowLookDetail(item)" @click="goSystem(item.pushId,item.pushType,item.courseType,item.linkUrl, item)">
              查看详情
              <span class="iconfont c-fc-gray c-fs14 c-ml10 theme-fc">&#xe635;</span>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="c-ph24 c-pt20" v-if="type == 2">
      <div v-for="(item, index) in messageList" :key="index">
        <div class="c-ph20 c-mb20 c-bg-white c-br8" v-if="item.pushType == 9">
          <div class="c-flex-column">
            <span class="c-fs22 c-fc-sblack c-lh c-pv24 c-bd-b1-ef">您推荐的用户{{item.nickname}}已成功注册啦！{{companyAuth.enablePoints == 1 && companyAuth.enableRegisterPoint == 1 ? '恭喜您获得一笔'+companyAuth.integrateName1+'奖励，请到'+companyAuth.integrateName1+'明细查看。' : ''}}</span>
            <div class="c-fs20 c-fc-gray c-pv24">{{item.pushTime}}</div>
          </div>
        </div>

        <div class="c-ph20 c-mb20 c-bg-white c-br8" v-if="item.pushType == 8">
          <div class="c-pv24 c-bd-b1-ef c-flex-column">
            <span class="c-fs26 c-fc-xblack c-lh c-fw-b">恭喜您升级/续费成功!</span>
            <span class="c-fs22 c-fc-sblack c-lh c-mt24">会员类型：{{item.title}}</span>
          </div>
          <div class="c-fs20 c-fc-gray c-pv24">升级时间：{{item.pushTime}}</div>
        </div>

        <div class="c-ph20 c-mb20 c-bg-white c-br8" v-if="item.pushType == 10">
          <div class="c-pv24 c-bd-b1-ef c-flex-column">
            <span class="c-fs26 c-fc-xblack c-lh c-fw-b">{{item.nickname}}已成功绑定手机号！</span>
            <span class="c-fs22 c-fc-sblack c-lh c-mt24">绑定手机：{{item.content}}</span>
          </div>
          <div class="c-fs20 c-fc-gray c-pv24">{{item.pushTime}}</div>
        </div>

        <div class="c-ph20 c-mb20 c-bg-white c-br8" v-if="item.pushType == 11">
          <div class="c-pv24 c-bd-b1-ef c-flex-column">
            <span class="c-fs26 c-fc-xblack c-lh c-fw-b">{{item.nickname}}{{item.pushId == 1 ? '将您设置为员工啦！' : '取消了您的员工身份！'}}</span>
            <span class="c-fs22 c-fc-sblack c-lh c-mt24">请到“我的->个人信息”查看。</span>
          </div>
          <div class="c-fs20 c-fc-gray c-pv24">{{item.pushTime}}</div>
        </div>

        <div class="c-ph20 c-mb20 c-bg-white c-br8" v-if="item.pushType == 14">
          <div class="c-pv24 c-bd-b1-ef c-flex-column">
            <span class="c-fs26 c-fc-xblack c-lh c-fw-b" v-if="item.pushId != 3">您的{{item.isSubType ? item.subName : item.content == 3 ? customName.agentName : item.content == 5 ? customName.partnerName : item.content == 6 ? customName.branchName : item.content == 7 ? customName.cooName : item.content == 8 ? customName.agencyName : item.content == 9 ? customName.agent6Name : item.content == 10 ? customName.agent7Name : item.content == 11 ? customName.agent8Name : customName.agent9Name}}身份{{item.pushId == 2 ? (item.content == 3 ? ('审核通过啦'+(item.nickname ? ',同时您的推荐人已更改为：'+item.nickname : '')) : '审核通过啦！') : (item.pushId == -1 ? '的申请被取消了！' : (item.pushId == -2 ? '被取消了！' : ''))}}</span>
            <span class="c-fs26 c-fc-xblack c-lh c-fw-b" v-if="item.pushId == 3">您的身份被更换为{{item.isSubType ? item.subName : item.content == 3 ? customName.agentName : item.content == 5 ? customName.partnerName : item.content == 6 ? customName.branchName : item.content == 7 ? customName.cooName : item.content == 8 ? customName.agencyName : item.content == 9 ? customName.agent6Name : item.content == 10 ? customName.agent7Name : item.content == 11 ? customName.agent8Name : customName.agent9Name}} {{item.nickname ? '同时您的推荐人已更改为：'+item.nickname : ''}}</span>
            <span class="c-fs22 c-fc-sblack c-lh c-mt24">请到“我的->{{customName.serviceProviderName}}”查看。</span>
            <span class="c-fs22 c-fc-sblack c-lh c-mt24">{{timeFormat(item.pushTime)}}</span>
          </div>
          <div class="c-fs20 c-fc-gray c-pv24">{{item.pushTime}}</div>
        </div>

        <div class="c-ph20 c-mb20 c-bg-white c-br8" v-if="item.pushType == 15">
          <div class="c-pv24 c-bd-b1-ef c-flex-column">
            <span class="c-fs26 c-fc-xblack c-lh c-fw-b">商家给您{{item.content > 0 ? '赠送' : '取消'}}{{Math.abs(item.content)}}{{item.pushId == 2 ? '个vip' : item.pushId == 3 ? `个${customName.agentName}` : item.pushId == 4 ? '个svip' : item.pushId == 5 ? `个${customName.partnerName}` : item.pushId == 6 ? `个${customName.branchName}` : item.pushId == 7 ? `个${customName.cooName}` : item.pushId == 8 ? `个${customName.agencyName}` : item.pushId == 9 ? `个${customName.agent6Name}` : item.pushId == 10 ? `个${customName.agent7Name}` : item.pushId == 11 ? `个${customName.agent8Name}` : item.pushId == 12 ? `个${customName.agent9Name || ''}` : ''}}{{item.pushId == 0 ? '元' : '名额'}}</span>
            <span class="c-fs22 c-fc-sblack c-lh c-mt24">请到“我的->{{customName.serviceProviderName}}”查看。</span>
            <span class="c-fs22 c-fc-sblack c-lh c-mt24">{{timeFormat(item.pushTime)}}</span>
          </div>
          <div class="c-fs20 c-fc-gray c-pv24">{{item.pushTime}}</div>
        </div>

        <div class="c-ph20 c-mb20 c-bg-white c-br8" v-if="item.pushType == 16">
          <div class="c-pv24 c-bd-b1-ef c-flex-column">
            <span class="c-fs26 c-fc-xblack c-lh c-fw-b">商家给您{{item.content > 0 ? '赠送' : '取消'}}{{Math.abs(item.content)}}{{companyAuth ? companyAuth.integrateName1 : ''}}</span>
            <span class="c-fs22 c-fc-sblack c-lh c-mt24">请到“我的->{{companyAuth.integrateName1}}”查看。</span>
          </div>
          <div class="c-fs20 c-fc-gray c-pv24">{{item.pushTime}}</div>
        </div>

        <div class="c-ph20 c-mb20 c-bg-white c-br8" v-if="item.pushType == 19">
          <div class="c-pv24 c-bd-b1-ef c-flex-column">
            <span class="c-fs26 c-fc-xblack c-lh c-fw-b">您的推荐人更改为：{{item.nickname}}</span>
            <span class="c-fs22 c-fc-sblack c-lh c-mt24">请到“我的->个人信息”查看。</span>
          </div>
          <div class="c-fs20 c-fc-gray c-pv24">{{item.pushTime}}</div>
        </div>
        <div class="c-ph20 c-mb20 c-bg-white c-br8" v-if="item.pushType == 18 || item.pushType == 29">
          <div class="c-pv24 c-bd-b1-ef c-flex-column">
            <span class="c-fs26 c-fc-xblack c-fw-b">{{item.title == '-1' ? '很遗憾，由于人数不足拼团失败了！' : (item.title == '-2' ? '很遗憾，由于票不足拼团失败了！' : (item.title == '-3' ? '很遗憾，由于面授课库存不足拼团失败了' : (item.title == '-4' ? '很遗憾，由于报名人数已满拼团失败了！' : '恭喜您，拼团成功！')))}}</span>
            <span class="c-fs22 c-fc-sblack c-mt24">{{item.content}}</span>
            <span class="c-fs22 c-fc-sblack c-mt24" v-if="item.title == '-1' || item.title == '-4'">您的退款已经提交审核，感谢您的参与！</span>
            <span class="c-fs22 theme-fc c-mt24" v-if="item.title == '1'" @click="goCollage(item.linkUrl)">点击查看</span>
          </div>
          <div class="c-fs20 c-fc-gray c-pv24">{{item.pushTime}}</div>
        </div>
        <div class="c-ph20 c-mb20 c-bg-white c-br8" v-if="item.pushType == 21">
          <div class="c-pv24 c-bd-b1-ef c-flex-column">
            <span class="c-fs26 c-fc-xblack c-fw-b">友情灌溉通知</span>
            <span class="c-fs22 c-fc-sblack c-mt24">{{item.title}}</span>
            <span class="c-fs22 c-fc-sblack c-mt24">恭喜你！好友已经帮你助力成功了，快去领取吧！</span>
            <span class="c-fs22 theme-fc c-mt24" v-if="item.title == '1'" @click="goHelpDetail(item.pushId)">点击查看</span>
          </div>
          <div class="c-fs20 c-fc-gray c-pv24">{{item.pushTime}}</div>
        </div>
        <div class="c-ph20 c-mb20 c-bg-white c-br8" v-if="item.pushType == 35">
          <div class="c-pv24 c-bd-b1-ef c-flex-column">
            <span class="c-fs26 c-fc-xblack c-fw-b">{{item.title == '1' ? '恭喜您，商品已砍价成功!' : item.title == '-1' ? '商品砍价结束' : ''}}</span>
            <span class="c-fs22 c-fc-sblack c-mt24">{{item.content}}</span>
            <span class="c-fs22 c-fc-sblack c-mt24" v-if="item.title == '-1'">砍价已结束！请尝试重新发起砍价吧!</span>
            <span class="c-fs22 theme-fc c-mt24" v-if="item.title == '1'" @click="goCollage(item.linkUrl)">点击查看</span>
          </div>
          <div class="c-fs20 c-fc-gray c-pv24">{{item.pushTime}}</div>
        </div>
        <div class="c-ph20 c-mb20 c-bg-white c-br8" v-if="item.pushType == 22">
          <div class="c-pv24 c-bd-b1-ef c-flex-column">
            <span class="c-fs26 c-fc-xblack c-fw-b">友情灌溉通知</span>
            <span class="c-fs22 c-fc-sblack c-mt24">{{item.title}}</span>
            <span class="c-fs22 c-fc-sblack c-mt24">非常遗憾！你的友情灌溉因人数不够，助力失败了。</span>
            <span class="c-fs22 theme-fc c-mt24" v-if="item.title == '1'" @click="goHelpDetail(item.pushId)">点击查看</span>
          </div>
          <div class="c-fs20 c-fc-gray c-pv24">{{item.pushTime}}</div>
        </div>
        <div class="c-ph20 c-mb20 c-bg-white c-br8" v-if="item.pushType == 39">
          <div class="c-pv24 c-bd-b1-ef c-flex-column">
            <span class="c-fs26 c-fc-xblack c-lh c-fw-b">您的上级股东更改为：{{item.nickname}}</span>
            <span class="c-fs22 c-fc-sblack c-lh c-mt24">请到“我的->个人信息”查看。</span>
          </div>
          <div class="c-fs20 c-fc-gray c-pv24">{{item.pushTime}}</div>
        </div>
        <div class="c-ph20 c-mb20 c-bg-white c-br8" v-if="item.pushType == 40">
          <div class="c-pv24 c-bd-b1-ef c-flex-column">
            <span class="c-fs26 c-fc-xblack c-lh c-fw-b">您的上级股东已清除</span>
            <span class="c-fs22 c-fc-sblack c-lh c-mt24">请到“我的->个人信息”查看。</span>
          </div>
          <div class="c-fs20 c-fc-gray c-pv24">{{item.pushTime}}</div>
        </div>
        <div class="c-ph20 c-mb20 c-bg-white c-br8" v-if="item.pushType == 41 || item.pushType == 42">
          <div class="c-pv24 c-bd-b1-ef c-flex-column">
            <span class="c-fs26 c-fc-xblack c-lh c-fw-b">{{item.pushType == 41 ? '您的提现申请审核成功' : '您的提现申请审核失败'}}</span>
            <span class="c-fs22 c-fc-sblack c-lh c-mt24">{{item.pushType == 41 ? '请注意查收。' : '请重新申请。'}}</span>
          </div>
          <div class="c-fs20 c-fc-gray c-pv24">{{item.pushTime}}</div>
        </div>
        <div @click="goLiveRoom(item.linkUrl)" class="c-ph20 c-mb20 c-bg-white c-br8" v-if="item.pushType == 44">
          <div class="c-pv24 c-bd-b1-ef c-flex-column">
            <span class="c-fs26 c-fc-xblack c-fw-b">直播间邀请活动中奖通知</span>
            <span class="c-fs22 c-fc-sblack c-mt24">{{item.title}}</span>
            <span class="c-fs22 c-fc-sblack c-mt24">{{item.content}}</span>
          </div>
          <div class="c-flex-row c-justify-sb c-aligni-center">
            <div class="c-fs20 c-fc-gray c-pv24">{{item.pushTime}}</div>
            <span class="c-fs22 theme-fc">点击查看</span>
          </div>
        </div>
      </div>
    </div>

    <div class="c-ph24" v-if="type == 3 && companyAuth.enableQuestionModule == 1">
      <div class="c-flex-row c-pt60 c-pb28 c-bd-b1-ef c-p" v-for="(item,index) in messageList" :key="index">
        <img v-if="item.pushType == 4 && item.isHidden == -1 " :src="require('@/assets/no_login_head.png')" class="c-ww100 c-hh100 c-brp50" />
        <img v-else-if="item.pushType == 4" :src="item.headimgurl || require('../../assets/defult_head.png')" class="c-ww100 c-hh100 c-brp50" />
        <img v-else :src="$addXossFilter(item.avatar, require('../../assets/defult_head.png'))" class="c-ww100 c-hh100 c-brp50" />
        <div class="c-flex-column c-flex-grow1 c-ml16 c-w0 c-flex-shrink0">
          <span class="c-fs28 c-fc-blue">{{item.pushType == 4 ? (item.isHidden == -1 ? '匿名者向您' : `${item.nickname}向您`) : `${item.answerName}回复您`}}{{item.pushType == 4 ? item.type == 1 ? `${questionCustom == 1 ? '预约' : '提问'}` : '追问' : ''}}</span>
          <span class="c-fs24 c-fc-sxblack c-mt32 c-text-ellipsis3">{{item.detail}}</span>
          <span class="c-fs24 theme-fc c-mt44" v-if="item.questionStatus !=-1" @click="goQaDetail(item.pushId, item.pushType)">点击查看</span>
          <span class="c-fs18 c-fc-gray c-mt20">{{timeFormat(item.pushTime)}}</span>
        </div>
        <img src="https://kposshzcdn.ckjr001.com/admin/material/9_material_admin/image/assets/i/wap/qa/del.png" alt="" class="c-pa c-p-r0 p-tm20 c-ww100" v-if="item.questionStatus == -1">
      </div>
    </div>

    <div class="c-ph24" v-if="type == 4">
      <div class="c-flex-row c-pt60 c-pb28 c-bd-b1" v-for="(item,index) in messageList" :key="index">
        <img v-lazy="item.headimgurl != '' && item.headimgurl != null ? item.headimgurl : require('../../assets/defult_head.png')" class="c-ww100 c-hh100 c-brp50" />
        <div class="c-flex-column c-flex-grow1 c-ml16 c-w0 c-flex-shrink0">
          <template v-if="item.prodType == cfrom.circle">
            <span class="c-fs26 c-fc-xblack">{{item.nickname ? item.nickname : '未知'}}{{item.title}}</span>
            <span class="c-fs22 c-fc-sblack c-mt24" v-if="item.content && item.content.length > 0">{{item.content}}</span>
          </template>
          <template v-else>
            <span class="c-fs26 c-fc-xblack">{{item.nickname ? (item.nickname == "管理员" ? item.nickname : nameLength(item.nickname, 2)) : '未知'}}回复了您的{{item.prodType == cfrom.shopComment ? '商品评价' : '评论'}}</span>
            <span class="c-fs22 c-fc-sblack c-mt24" v-if="item.courseName && item.courseName.length > 0">{{item.courseName}}</span>
          </template>
          <span class="c-fs22 theme-fc c-mt24" @click="goCourseDetail(item.prodType,item.pushId,item.courseType,item.comId)">点击查看</span>
          <span class="c-fs20 c-fc-gray c-mt20">{{timeFormat(item.pushTime)}}</span>
        </div>
      </div>
    </div>

    <div class="c-ph24 c-pt20" v-if="type == 5">
      <div class="c-ph20 c-bg-white c-br8" :class="index == 0 ? '' : 'c-mt20'" v-for="(item,index) in messageList" :key="index" v-if="parseInt(item.content).toString().length < 11">
        <div class="c-flex-column c-pv24 c-bd-b1-ef">
          <template v-if="item.pushType == 49">
            <span class="c-fs26 c-fc-xblack c-lh40 c-fw-b">您上个月的收益预计税额已统计，请到个人中心--我的账户查看！</span>
            <span class="c-fs22 c-fc-sblack c-lh c-mt24">上个月自动到微信零钱的收益：{{Number(item.content.amount).toFixed(2)}}元</span>
            <span class="c-fs22 c-fc-sblack c-lh c-mt24">上个月预计个人所得税：{{item.content.invoiceAmount}}元</span>
            <span class="c-fs22 c-fc-sblack c-lh c-mt24">个人所得税：{{item.content.formula + '=' + item.content.invoiceAmount}}元</span>
          </template>
          <template v-else>
            <span class="c-fs26 c-fc-xblack c-lh c-fw-b">您有一笔新的收益到账，请到个人中心查看！</span>
            <span class="c-fs22 c-fc-sblack c-lh c-mt24">收益金额：{{Number(item.content).toFixed(2)}}元</span>
            <span class="c-fs22 c-fc-sblack c-lh c-mt24">收益来源：{{item.nickname}}</span>
            <span class="c-fs22 c-fc-sblack c-lh c-mt24">到账时间：{{item.pushTime}}</span>
          </template>
        </div>
        <div class="c-fs20 c-fc-gray c-pv24">{{item.pushTime}}</div>
      </div>

    </div>

    <div class="c-ph24" v-if="type == 6">
      <div class="c-flex-column c-aligni-center" v-for="(item,index) in messageList" :key="index">
        <h2 class="c-fw-n c-fs18 c-fc-white c-ph32 c-pv12 c-bg-d7 c-br10 c-mt44">{{item.pushTime.split(" ")[0]}}</h2>
        <div class="c-bg-white c-br10 c-ph30 c-pv26 c-w100 c-mt20 c-flex-column bs">
          <h2 class="c-fw-n c-fs24 c-lh36 c-fc-sxblack">客户跟进提醒</h2>
          <span class="c-fs18 c-fc-gray c-mt14">{{item.pushTime.split(" ")[1]}}</span>
          <div class="c-w100 c-flex-row c-mt32">
            <img :src="$addXossFilter(item.headimgurl, require('../../assets/defult_head.png'))" class="c-ww80 c-hh80 c-brp50" />
            <div class="c-flex-column c-flex-grow1 c-ml16 c-w0 c-flex-shrink0 c-hh80 c-justify-sa">
              <span class="c-fs24 c-fc-sxblack c-lh">{{item.nickname}}</span>
              <span class="c-fs18 c-fc-gray">打开了您的分享链接</span>
            </div>
          </div>
          <div class="c-lh28 c-fs24 c-fc-sxblack c-mt32 c-mb30 c-ww-bw">分享来源：{{item.content}}</div>
        </div>
      </div>
    </div>
    <loading-status-tem :showLoading="isLoading" :noMoreData="is_page == false && (messageList && messageList.length > 0)" :noData="!messageList || messageList.length == 0" :noDataText="'暂无相关消息'"></loading-status-tem>
  </div>
</template>

<script>
import loadingStatusTem from "@/components/templates/common/loadingStatusTem.vue";
import { utilJs } from "@/utils/common.js"
import { goDetails } from "@/utils/goDetails.js";
let msgLineHeight = 20;//默认行高20px
let subTypeArr = [];
export default {
  name: 'MessageList',
  components: {
    loadingStatusTem
  },
  props: [],
  beforeCreate() {

  },
  data() {
    return {
      companyAuth: JSON.parse(localStorage.getItem("companyAuth")),
      type: 0,
      is_page: false,
      page: 1,
      limit: 10,
      messageList: [],
      isLoading: false,
      customName: JSON.parse(localStorage.getItem("customName")),
      cfrom: global.ckFrom,
      questionCustom: localStorage.getItem("questionCustom"), //定制阿卡西线上学院
    }
  },
  created() {
    utilJs.appShare(this);
  },
  mounted() {

  },
  computed: {
    isShowLookDetail() { // 显示退款详情按钮
      return function (item) {
        // 不是其他自定义链接类型，或者有链接，不是订单退款类型（27）
        return !(item.pushType == 12 && (item.linkUrl == '' || item.linkUrl == null)) && item.pushType != 27 && item.pushType != 28 && item.pushType != 32
      }
    },
  },
  watch: {

  },
  methods: {
    //点击显示更多
    clickShowMore(index) {
      if (this.messageList[index].showAllContent) {
        this.$refs[`msgContent${index}`][0].style.height = msgLineHeight * 4 + "px";
      } else {
        this.$refs[`msgContent${index}`][0].style.height = '';
      }
      this.$set(this.messageList[index], "showAllContent", !this.messageList[index].showAllContent);
    },
    //跳转到我的助力
    goHelpDetail: function (faId) {
      this.$routerGo(this, "push", {
        path: "/homePage/task/task",
        query: { 'faId': faId, 'refereeId': localStorage.getItem("userId") }
      });
    },
    //跳转到用户自定义的链接
    goCollage: function (linkUrl) {
      // window.location.href = linkUrl;
      if (linkUrl) {
        let path = linkUrl.split("#")[1];
        this.$routerGo(this, "push", {
          path: path
        })
      } else {
        this.$routerGo(this, "push", {
          path: '/'
        })
      }
    },
    timeFormat: function (timeStr) {
      return utilJs.changeQaTime(timeStr);
    },
    //跳转到问答详情
    goQaDetail: function (pushId, pushType) {
      this.$routerGo(this, "push", {
        path: "/homePage/qa/answerDetail",
        query: { questionDetailId: pushId }
      });
    },
    goSystem: function (id, type, courseType, linkUrl, data) {
      if (data.groupId && data.groupId > 0) {
        this.shopMessageCheck(data);
      }
      //推送类型，1：课程，2：活动，3：专栏，12：外部链接,127独立直播间
      if (type == 1) {
        switch (courseType) {
          case 0:
            this.$routerGo(this, "push", {
              path: "/homePage/course/video",
              query: { courseId: id, extId: -1, ckFrom: global.ckFrom.course }
            });
            break;
          case 1:
            this.$routerGo(this, "push", {
              path: "/homePage/course/voice",
              query: { courseId: id, extId: -1, ckFrom: global.ckFrom.course }
            });
            break;
          case 2:
            this.$routerGo(this, "push", {
              path: "/homePage/course/imgText",
              query: { courseId: id, extId: -1, ckFrom: global.ckFrom.course }
            });
            break;
        }
      } else if (type == 2) {
        this.$routerGo(this, "push", {
          path: "/activity/activityDetail",
          query: { ActivityNo: id }
        })
      } else if (type == 3) {
        this.$routerGo(this, "push", {
          path: "/homePage/column/columnDetail",
          query: { cId: -1, ckFrom: global.ckFrom.column, extId: id }
        });
      } else if (type == 51) {
        this.$routerGo(this, "push", {
          path: "/homePage/live/liveDetail",
          query: { liveId: id }
        });
      } else if (type == 127) {
        this.$routerGo(this, "push", {
          path: "/homePage/live/livePersonalDetail",
          query: { liveId: id }
        });
      } else if (type == 12) {
        if (linkUrl) {
          if (linkUrl.includes("http") || linkUrl.includes("https")) {
            utilJs.locationHref(linkUrl);
          } else {
            utilJs.locationHref("http://" + linkUrl);
          }
        }
      } else if (type == 23) { // 约课
        this.$routerGo(this, "push", {
          path: "/activity/activityDetail",
          query: { ActivityNo: id, from: 'reservation' }
        });
      } else if (type == 24 || type == 25 || type == 26) { // 约课复训取消预约、退款 跳转去预约票券 签到退款消息
        this.$routerGo(this, "push", {
          path: "/activity/ticketNum",
          query: { activityId: data.prodId, reId: id, from: 'reservation' } // 用到的是主题id（rtId）对应的是prodId
        });
      } else if (type == 31 || type == 33) {
        this.$routerGo(this, "push", {
          path: '/member/myActivity/myActivity',
          query: {
            ActivityNo: id,
            searchText: data.name,
          }
        })
      } else if (type == 30 || type == 43) { // 30 下单 43 售后退款
        this.$routerGo(this, "push", {
          path: '/mall/mallOrder/orderDetail',
          query: {
            goId: id
          }
        })
      } else if (type == 36 || type == 37 || type == 38) {
        // 社群超库存退款, 打卡超库存退款, 训练营库存不足退款
        if (linkUrl) {
          if (linkUrl.includes("http") || linkUrl.includes("https")) {
            utilJs.locationHref(linkUrl);
          } else {
            utilJs.locationHref("http://" + linkUrl);
          }
        }
      } else if (type == 46) {
        this.$routerGo(this, "push", {
          path: '/homePage/package/packageDetail',
          query: {
            combosId: id
          }
        })
      } else if (type == 47) {
        this.$routerGo(this, "push", {
          path: '/homePage/camp/campDetail',
          query: {
            campId: id
          }
        })
      }
    },
    //店铺消息查看
    shopMessageCheck (cItem) {
      utilJs.postMethod(global.apiurl + 'messages/shopMessageCheck', {opId: cItem.sourceId}, res => {
      })
    },
    goCourseDetail: function (prodType, courseId, courseType, comId) {
      let prodId = prodType == this.cfrom.shopComment ? comId : courseId;
      if (prodType == this.cfrom.circle) {
        this.$routerGo(this, "push", {
          path: "/homePage/circle/circleDetail",
          query: {
            circleFeedsId: courseId,
          }
        })
      } else {
        goDetails(this, prodType, prodId, '', courseType);
      }
    },
    nameLength(name, length) {
      return utilJs.nameLength(name, length)
    },
    //通过消息类型获取消息列表
    getMessages: function () {
      if (!this.isLoading) {
        this.isLoading = true;
        let $this = this;
        utilJs.getMethod(global.apiurl + 'messages?msgType=' + this.type + '&page=' + this.page + '&limit=' + this.limit, function (res) {
          $this.companyAuth = localStorage.getItem("companyAuth") ? JSON.parse(localStorage.getItem("companyAuth")) : '';
          $this.customName = localStorage.getItem("customName") ? JSON.parse(localStorage.getItem("customName")) : '';
          if ($this.type == 1) {
            res.data.data.map((item) => {
              item.showAllContent = false;
              item.hasShowMore = false;
              return item;
            });
          }
          let list = res.data.data;
          if ($this.page == 1) {
            subTypeArr = res.subTypeName;
          }
          for (let i = 0; i < list.length; i++) {
            if (list[i].pushType == 14 && subTypeArr && subTypeArr.length > 0) {
              list[i].isSubType = true;
              list[i].subType = list[i].subType ? list[i].subType : 0;
              let tItem = subTypeArr.filter((item) => {
                return item.subType == list[i].subType;
              })
              if (tItem && tItem.length > 0) {
                list[i].subName = tItem[0].name;
              }
            }
          }
          if ($this.page == 1) {
            $this.messageList = list;
            $this.type == 1 && res.data.data.length > 0 && $this.initShowMore();
          } else {
            $this.messageList = $this.messageList.concat(list);
            $this.type == 1 && $this.initShowMore(($this.page - 1) * $this.limit);
          }
          $this.page = res.data.current_page < res.data.last_page ? ($this.page + 1) : $this.page;
          $this.is_page = res.data.current_page < res.data.last_page;
          $this.isLoading = false;
        });
      }
    },
    //去直播间
    goLiveRoom(url) {
      if (url) {
        utilJs.locationHref(url);
      }
    },
    /**
     * startIndex 开始的位置，防止每次都要获取整个列表
     * 获取行高,判断当前内容是否超过4行，超过，则有显示更多按钮
     *  */
    initShowMore(startIndex = 0) {
      this.$nextTick(() => {
        try {
          msgLineHeight = window.getComputedStyle(this.$refs[`msgContent${0}`][0]).lineHeight.split("px")[0].split(".")[0];
        } catch (error) {
          msgLineHeight = 20;
        }
        for (let i = startIndex; i < this.messageList.length; i++) {
          if (this.$refs[`msgContent${i}`][0].offsetHeight > msgLineHeight * 4) {
            this.$refs[`msgContent${i}`][0].style.height = msgLineHeight * 4 + "px";
            this.$set(this.messageList[i], "hasShowMore", true);
          }
        }
      });
    },

    //分享
    wechatShare: function () {
      utilJs.wechatConfig("", "", "", "", function () { });
    },
    //手机端分享
    appShare: function () {
      var shareUrl =
        window.location.href.split("#")[0] +
        "#/" +
        "?refereeId=" +
        localStorage.getItem("userId");
      utilJs.appShareTrue("", "", shareUrl, "");
    },
    windowScrollFunction: function () {
      let that = this;
      utilJs.handleLoading(function () {
        if (that.is_page == true) {
          that.getMessages();
        }
      });
    }
  },
  activated() {
    setDocumentTitle("消息列表");// eslint-disable-line
    this.is_page = false;
    this.page = 1;
    this.messageList = [];
    this.type = this.$route.query.type;
    this.getMessages();
    this.isLoading = false;
    window.addEventListener('scroll', this.windowScrollFunction);
    switch (this.type) {
      case 1:
        this.$store.state.oem_store.msgCount.system = 0;
        this.$store.state.oem_store.msgCount.system_time = "";
        break;
      case 2:
        this.$store.state.oem_store.msgCount.push = 0;
        this.$store.state.oem_store.msgCount.push_time = "";
        break;
      case 3:
        this.$store.state.oem_store.msgCount.question = 0;
        this.$store.state.oem_store.msgCount.question_time = "";
        break;
      case 4:
        this.$store.state.oem_store.msgCount.comment = 0;
        this.$store.state.oem_store.msgCount.comment_time = "";
        break;
      case 5:
        this.$store.state.oem_store.msgCount.income = 0;
        this.$store.state.oem_store.msgCount.income_time = "";
        break;
      case 6:
        this.$store.state.oem_store.msgCount.share = 0;
        this.$store.state.oem_store.msgCount.share_time = "";
        break;
      default:
        break;
    }

    this.wechatShare();
  },
  deactivated() {
    this.is_page = false;
    window.removeEventListener('scroll', this.windowScrollFunction);
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.c-bd-b1-ef {
  border-bottom: 1px solid #EFEFEF;
}
</style>
